package cn.schoolwow.util.module.query.instanceList.flow.filter;

import cn.schoolwow.quickflow.domain.FlowContext;
import cn.schoolwow.quickflow.flow.BusinessFlow;
import cn.schoolwow.util.module.query.instanceList.domain.InstanceListQueryOption;

import java.util.ArrayList;
import java.util.List;

public class SetFilterInstanceListFlow implements BusinessFlow {
    @Override
    public void executeBusinessFlow(FlowContext flowContext) throws Exception {
        InstanceListQueryOption instanceQueryOption = flowContext.checkInstanceData(InstanceListQueryOption.class);
        if(null==instanceQueryOption.collection){
            flowContext.brokenCurrentFlow("列表为空");
        }
        List filterInstanceList = new ArrayList();
        for(Object instance:instanceQueryOption.collection){
            filterInstanceList.add(instance);
        }
        flowContext.putTemporaryData("filterInstanceList", filterInstanceList);
    }

    @Override
    public String name() {
        return "设置过滤实例数组";
    }
}
